package com.ymatou.apigateway.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.apigateway.parameter.AesUtil;
import com.ymatou.apigateway.parameter.DeliverOrder;
import com.ymatou.apigateway.parameter.OpenapiReq;
import com.ymatou.apigateway.parameter.SendLogisticsResult;
import com.ymatou.apigateway.parameter.SendLogisticsReturn;
import com.ymatou.apigateway.parameter.SendlogisticsBean;
import com.ymatou.apigateway.service.OpenapiService;
import com.ymatou.apigateway.service.V1sendlogisticsCall;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.parameter.enums.LogisticsTypeEnum;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.database.model.Application;
import com.ymttest.database.model.AuthCode;
import com.ymttest.database.sqlwapper.OpenApiWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
/**
*订单发货
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_V1sendlogistics {

	private static OpenapiReq openapiReq;
	private static SendlogisticsBean v1sendlogisticsBean;
	private static V1sendlogisticsCall v1sendlogisticsCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("订单发货");
	}

	@Before
	public void caseUp() {
		openapiReq = new OpenapiReq();
		openapiReq.setMethod("ymatou.order.deliver");

		v1sendlogisticsBean = new SendlogisticsBean();
		v1sendlogisticsCall = new V1sendlogisticsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(v1sendlogisticsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_001() {
		Logger.start(true, "订单发货");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService
					.placeOrderBylogisticsType(LogisticsTypeEnum.China);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();

			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();

			new OrderCallService().orderPayRequest(userId, price, tradingId);

			new OrderCallService().acceptOrder(orderId, sellerId);

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y073");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(12));
			deliverOrder.setIs_domestic_delivery(false);

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(Long.valueOf(sellerId)).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

			SendLogisticsResult sendLogisticsResult = v1sendlogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn returnresult = sendLogisticsResult.getResults()
					.get(0);

			Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
					.getOrder_id(), (long) returnresult.getOrder_id(), "验证Code");
			Logger.verifyEquals(true, returnresult.isExec_success(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_002() {
		Logger.start(true, "订单发货-order_id空");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setLogistics_company_id("Y073");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(11));
			deliverOrder.setIs_domestic_delivery(false);

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			long sellerId = Long.valueOf(EnvSetup.getData("SellerId"));

			Application application = openApiWapper
					.selectApplicationBySellerId(sellerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

			SendLogisticsResult results = v1sendlogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn result = results.getResults().get(0);

			Logger.verifyEquals("订单不存在", result.getMsg(), "验证msg");
			Logger.verifyEquals(0, result.getOrder_id(), "验证Code");
			Logger.verifyEquals(false, result.isExec_success(), "验证Code");

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_003() {
		Logger.start(true, "订单发货-logistics_company_id空");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService
					.placeOrderBylogisticsType(LogisticsTypeEnum.China);
			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();

			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();

			new OrderCallService().orderPayRequest(userId, price, tradingId);

			new OrderCallService().acceptOrder(orderId, sellerId);

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(11));
			deliverOrder.setIs_domestic_delivery(false);

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(Long.valueOf(sellerId)).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

			SendLogisticsResult results = v1sendlogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn result = results.getResults().get(0);

			Logger.verifyEquals("物流公司买手不可用", result.getMsg(), "验证Code");
			Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
					.getOrder_id(), (long) result.getOrder_id(), "验证Code");
			Logger.verifyEquals(false, result.isExec_success(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_004() {
		Logger.start(true, "订单发货-tracking_number空");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService
					.placeOrderBylogisticsType(LogisticsTypeEnum.China);
			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();

			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();

			new OrderCallService().orderPayRequest(userId, price, tradingId);

			new OrderCallService().acceptOrder(orderId, sellerId);

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y073");
			deliverOrder.setIs_domestic_delivery(false);

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(Long.valueOf(sellerId)).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

			SendLogisticsResult results = v1sendlogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn result = results.getResults().get(0);

			Logger.verifyEquals("面单号为空", result.getMsg(), "验证msg");
			Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
					.getOrder_id(), (long) result.getOrder_id(), "验证Code");
			Logger.verifyEquals(false, result.isExec_success(), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_006() {
		Logger.start(true, "订单发货-is_domestic_delivery空");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(112531246);
			deliverOrder.setLogistics_company_id("Y073");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(12));

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			long sellerId = Long.valueOf(EnvSetup.getData("SellerId"));

			Application application = openApiWapper
					.selectApplicationBySellerId(sellerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

			SendLogisticsResult results = v1sendlogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn result = results.getResults().get(0);

			Logger.verifyEquals("订单Api发货失败", result.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_007() {
		Logger.start(true, "订单发货-order_id不存在");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(1125312462);
			deliverOrder.setLogistics_company_id("Y073");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(11));
			deliverOrder.setIs_domestic_delivery(false);

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			long sellerId = Long.valueOf(EnvSetup.getData("SellerId"));

			Application application = openApiWapper
					.selectApplicationBySellerId(sellerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

			SendLogisticsResult results = v1sendlogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn result = results.getResults().get(0);

			Logger.verifyEquals("订单不存在", result.getMsg(), "验证msg");
			Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
					.getOrder_id(), (long) result.getOrder_id(), "验证Code");
			Logger.verifyEquals(false, result.isExec_success(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_008() {
		Logger.start(true, "订单发货-logistics_company_id不存在");
		try {
			PlaceOrderResp placeOrderResp = PlaceOrderService
					.placeOrderBylogisticsType(LogisticsTypeEnum.China);
			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();

			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();

			new OrderCallService().orderPayRequest(userId, price, tradingId);

			new OrderCallService().acceptOrder(orderId, sellerId);

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y073333");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(11));
			deliverOrder.setIs_domestic_delivery(false);

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(Long.valueOf(sellerId)).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

			SendLogisticsResult results = v1sendlogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn result = results.getResults().get(0);

			Logger.verifyEquals("物流公司买手不可用", result.getMsg(), "验证Code");
			Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
					.getOrder_id(), (long) result.getOrder_id(), "验证Code");
			Logger.verifyEquals(false, result.isExec_success(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_013() {
		Logger.start(true, "订单发货-多笔订单发货");
		try {

			List<DeliverOrder> orders = new ArrayList<>();
			int sellerId = 0;
			for (int i = 0; i < 4; i++) {
				PlaceOrderResp placeOrderResp = PlaceOrderService
						.placeOrderBylogisticsType(LogisticsTypeEnum.China);

				int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				int userId = placeOrderResp.getUserId();

				int tradingId = placeOrderResp.getTradingId();

				BigDecimal price = placeOrderResp.getPayAmount();

				new OrderCallService()
						.orderPayRequest(userId, price, tradingId);

				new OrderCallService().acceptOrder(orderId, sellerId);

				DeliverOrder deliverOrder = new DeliverOrder();

				deliverOrder.setOrder_id(orderId);
				deliverOrder.setLogistics_company_id("Y073");
				deliverOrder.setTracking_number(TestDataManager
						.getRandomNum(12));
				deliverOrder.setIs_domestic_delivery(false);

				orders.add(deliverOrder);

			}

			OpenApiWapper openApiWapper = new OpenApiWapper();

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(Long.valueOf(sellerId)).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

			SendLogisticsResult results = v1sendlogisticsCall
					.getSendLogisticsResult();

			for (int i = 0; i < results.getResults().size(); i++) {
				SendLogisticsReturn result = results.getResults().get(i);

				Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders()
						.get(i).getOrder_id(), (long) result.getOrder_id(),
						"验证Code");
				Logger.verifyEquals(true, result.isExec_success(), "验证Code");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_014() {
		Logger.start(true, "他人订单发货");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService
					.placeOrderBylogisticsType(LogisticsTypeEnum.China);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();

			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();

			new OrderCallService().orderPayRequest(userId, price, tradingId);

			new OrderCallService().acceptOrder(orderId, sellerId);

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y073");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(12));
			deliverOrder.setIs_domestic_delivery(false);

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(
							Long.valueOf(EnvSetup.getData("SellerId"))).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

			SendLogisticsResult sendLogisticsResult = v1sendlogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn returnresult = sendLogisticsResult.getResults()
					.get(0);

			Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
					.getOrder_id(), (long) returnresult.getOrder_id(), "验证Code");
			Logger.verifyEquals(false, returnresult.isExec_success(), "验证Code");
			Logger.verifyEquals("订单不存在", returnresult.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_015() {
		Logger.start(true, "订单发货一次超过10笔订单");
		try {

			List<DeliverOrder> orders = new ArrayList<>();

			for (int i = 0; i < 11; i++) {

				DeliverOrder deliverOrder = new DeliverOrder();

				deliverOrder.setOrder_id(22222222);
				deliverOrder.setLogistics_company_id("Y073");
				deliverOrder.setTracking_number(TestDataManager
						.getRandomNum(11));
				deliverOrder.setIs_domestic_delivery(false);

				orders.add(deliverOrder);

			}

			OpenApiWapper openApiWapper = new OpenApiWapper();

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(
							Long.valueOf(EnvSetup.getData("SellerId"))).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0001", v1sendlogisticsCall.getCode(), "验证Code");

			Logger.verifyEquals("deliverOrderInfos:单次发货不能超过10个订单",
					v1sendlogisticsCall.getMessage(), "验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_016() {
		Logger.start(true, "订单国内段转运发货发货");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService
					.placeOrderBylogisticsType(LogisticsTypeEnum.PackageDelivery);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();

			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();

			new OrderCallService().orderPayRequest(userId, price, tradingId);

			new OrderCallService().acceptOrder(orderId, sellerId);

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y073");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(12));
			deliverOrder.setIs_domestic_delivery(false);

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(Long.valueOf(sellerId)).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			deliverOrder.setTracking_number(TestDataManager.getRandomNum(12));
			deliverOrder.setIs_domestic_delivery(true);
			deliverOrder.setTran_ship(1);

			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0000", v1sendlogisticsCall.getCode(), "验证Code");

			SendLogisticsResult sendLogisticsResult = v1sendlogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn returnresult = sendLogisticsResult.getResults()
					.get(0);

			Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
					.getOrder_id(), (long) returnresult.getOrder_id(), "验证Code");
			Logger.verifyEquals(true, returnresult.isExec_success(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_017() {
		Logger.start(true, "发货业务参数Biz_content为null");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			Application application = openApiWapper
					.selectApplicationBySellerId(Long.valueOf(288484)).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			//openapiReq.setBiz_content("");
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0001", v1sendlogisticsCall.getCode(), "验证Code");

			Logger.verifyEquals("参数错误", v1sendlogisticsCall.getMessage(),
					"验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_V1sendlogistics_018() {
		Logger.start(true, "发货业务参数Biz_content为空");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			Application application = openApiWapper
					.selectApplicationBySellerId(Long.valueOf(288484)).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content("");
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=ymatou.order.deliver",
							app_id);
			v1sendlogisticsCall.setUrl(url);

			v1sendlogisticsCall.setData(openapiReq);
			v1sendlogisticsCall.callService();

			Logger.verifyEquals("0001", v1sendlogisticsCall.getCode(), "验证Code");

			Logger.verifyEquals("参数错误", v1sendlogisticsCall.getMessage(),
					"验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}